﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Models;
using BLL;
using AutoMapper;

namespace LMB.AIP.Tests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void 添加评论()
        {
            NewsTypeBLL bll = new NewsTypeBLL();
             NewsType com = new NewsType();
            com.addtime = DateTime.Now;
            com.Remark = "";
            com.isDel = false;
            com.orderNum = 12;
            com.typeName = "测试名称15"; 
            bool isok = bll.Insert(com);
            Assert.IsTrue(isok);
        }

        [TestMethod]
        public void TestMethod1()
        {
            //需要添加程序集 System.ValueTuple
            AddressDto dto = new AddressDto
            {
                Country = "中国",
                City = "Beijing",
                Street = "Dongzhimen Street",
                PostCode = "100001"
            };

            //初始化配置 一个Mapper。 就能相互装换了。
            Mapper.Initialize(a => a.CreateMap<AddressDto, Address>());

            Address address = Mapper.Map<Address>(dto);
            Assert.IsTrue(address.Country == "中国");
            Assert.IsTrue(address.City == "Beijing");

            AddressDto dto2 = Mapper.Map<AddressDto>(address);
            Assert.IsTrue(address.Country == "中国");
            Assert.IsTrue(address.City == "Beijing");

        }




    }

    public class Address
    {
        public string Country { get; set; }
        public string City { get; set; }
        public string Street { get; set; }
        public string PostCode { get; set; }
    }


    public class AddressDto
    {
        public string Country { get; set; }
        public string City { get; set; }
        public string Street { get; set; }
        public string PostCode { get; set; }
    }


}




